Note

There is no 2025 video available for this lesson yet. The video above is for a similar exercise using FME 2024, but the steps do not match exactly.

Learning Objectives

After completing this lesson, you’ll be able to:

Resources

Introduction

Now that Jennifer has a list of every tree in each park, she'd like to do the following:

  1. Filter the data to examine parks with trees.
  2. Find the most common genus among all park trees.
  3. Store the name of that genus in a new attribute.

1) Open Workspace and Run It

Jennifer opens the starting workspace (C:\FMEData\Workspaces\AdvancedDataTransformation\manipulate-lists-using-transformers.fmw) in FME Workbench (2025.0.1 or later).

She's added a TestFilter to filter park polygons that have trees.

She runs the workspace with feature caching enabled to store caches.

2) Create a Single List Using an Aggregator

To get the most common genus, Jennifer needs to combine the separate lists on each park feature into one big list. She can do that using an Aggregator transformer.

She adds one connected to the TestFilter's Trees output port.

She checks Generate List and adds only trees{}.GENUS_NAME to the list:

Aggregator configuration

She clicks OK, runs the workspace, and inspects the Aggregator's single output feature. The Feature Information window shows a new _list attribute with 125 elements. Each element stores the _trees list for each park, recording the genus of each tree:

New list attribute

Note

You could use a ListBuilder here instead, adding just _trees{}.GENUS_NAME to the list. The result would be the same as using the Aggregator.

3) Count Genus Names Using a ListHistogrammer

Jennifer adds a ListHistogrammer connected to the Aggregator's Aggregate port to count the times each genus appears in this new list.

She configures it to use _list{}.trees{}.GENUS_NAME as the Source List Attribute:

ListHistogrammer parameters

This configuration means the transformer will count the values of all GENUS_NAME attributes in the list and store the result in a new list attribute called _histogram.

She clicks OK, runs the workspace, and inspects the ListHistogrammer's Output cache. The Feature Information Window shows the single feature now has a _histogram list attribute.

Note

Make sure you collapse the large _list attribute still present on the feature; _histogram will be below it in the Feature Information Window.

Expanding that attribute shows the histogram's results. The most common value is stored as element 0 in the list, with the count attribute reflecting the number of times it appears in the list and the attribute value showing the genus name.

Histogram of genuses

Note

Take note of the top GENUS_NAME; you will need it for the quiz.

4) Store the Result Using an AttributeCreator

Now that Jennifer has found the most common genus, she'd like to store its name in an attribute. 

She adds an AttributeCreator attached to the ListHistogrammer's Output port to do so.

She adds a new Output Attribute called TopGenus. She clicks the ellipsis button to open the Text Editor:

Setting value for TopGenus

She double-clicks _histogram{}.value on the left under FME Feature Attributes to insert it:

Inserting _histogram{}.value

Here, she observes a behavior unique to list attributes. Instead of inserting  _histogram{}.value in the Text Editor, the List Element Selection dialog appears:

Selecting a list index

She leaves the value of 0 because she wants to extract the value of the first element in the list, which is the most common genus.

She clicks OK.

Note

To extract a single value from a list attribute, you must specify the index to use. Referring to all the values in a list in the Text or Arithmetic Editor or a transformer parameter is impossible. You need to use a transformer that accepts list values as input to do that.

If you don't want to hard-code the element number, use the Text Editor to specify an attribute instead of a number.

For example, you can use that method to find the least common genus. Use a ListElementCounter to count all the elements in _histogram, then supply the _element_count result as the index to retrieve the last value:

@Value(_histogram{@sub(@Value(_element_count),1)}.value)

Note that you must subtract 1 from _element_count to get the last entry in the list since _element_count starts at 1 and list indexes start at 0.

Jennifer runs the workspace and inspects the AttributeCreator's Output cache. The new attribute stores the name of the genus:

Results

Challenge

Find the most and least common genus for trees within parks.

How do you think the process outlined here will handle ties?

Note

Is there an easier way to get this answer from the starting data?

Yes, in this case, you could actually get the answer without using lists!

Give it a try!

If you get stuck, here are the steps for a simple way to do it:

  1. Use a Clipper to filter the trees to only trees within parks. 
  2. Use a StatisticsCalculator grouped by GENUS_NAME to get the Total Count for GENUS_NAME (or any attribute).
  3. Use a Sorter to sort GENUS_NAME.total_count Numeric Descending.
  4. The first feature reports the most common genus.

What's the lesson? Lists are powerful, but they are not always necessary! If you can design it, a non-list-based approach is often simpler. 

Next Steps

Jennifer could further process and analyze her lists using other list transformers. Here are some examples:

Operation Transformer
Count the number of trees in each park ListElementCounter
Find the maximum tree diameter ListSorter & ListIndexer
Find the count of each species ListHistogrammer
Create a list of species ListConcatentaor
Find which parks have an Oak tree ListSearcher
Create a table of park trees with the park name ListExploder
Find the average tree height in a park ListSummer
Find the minimum/maximum of tree diameters ListRangeExtractor

Refer to the FME documentation and the following example workspaces for more information on these transformers: